package com.dfhc.tag;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.BodyTagSupport;

import org.apache.commons.mvc.entity.Settled;
import org.apache.commons.mvc.util.ReflectUtil;
import org.apache.commons.mvc.util.UtilTool;

public class BaseTag extends BodyTagSupport
{
  private static final long serialVersionUID = 1L;

  public void write(String info)
  {
    try
    {
      JspWriter out = this.pageContext.getOut();
      out.print(info);
    }
    catch (Exception e) {
      e.printStackTrace();
    }
  }

  public HttpServletRequest getRequest()
   {
     return (HttpServletRequest)this.pageContext.getRequest();
   }
 
   public HttpServletResponse getResponse()
   {
     return (HttpServletResponse)this.pageContext.getResponse();
   }
 
   public HttpSession getSession()
   {
     return getRequest().getSession();
   }
 
   public String readRootUrl()
   {
     HttpServletRequest request = getRequest();
     return request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath();
   }
 
   /**
    * 获取区域md5值
    * @param name
    * @return
    */
   public String getTemplateRegionSign(String name) {
		return UtilTool.getBean().md5("templateRegionSign"+name);
	}
 }

